package linuxbox.filelib.logic;

import org.apache.log4j.Logger;
import java.sql.Timestamp;

import linuxbox.BoxStatic;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

public class FileLibEntry
{
  protected static Logger logger = Logger.getLogger(FileLibEntry.class.getName());
  //Make sure the data member name are the same as it is defined in its Bean object's SetupFields()
  public int id;
  public String name;
  public String filename;
  public int ownerid;
  public int parent;
  public long size;
  public boolean isfolder;
  public short version;
  public long attributes;
  public String description;
  public String type;
  public Timestamp createtime;
  public Timestamp lastmodifiedtime;

  public FileLibEntry()
  {
  }
/*
  id  int4 not null,
  name char(255) not null,
  filename char(255) not null,
  ownerid int4 not null,
  parent int4 not null,
  size int8 not null,
  isfolder int2 not NULL,
  type char(255),
  version int2 ,
  attributes int8 not NULL,
  description char(255),
  createtime timestamp  ,
  lastmodifiedtime timestamp ,

  primary key(id)
*/
  public int getID()
  {
    return id;
  }
  public void setId(int i)
  {
    id = i;
  }
  public String getName()
  {
    return name;
  }
  public void setName(String s)
  {
    name = s;
  }
  public String getFilename()
  {
    return filename;
  }
  public void setFilename(String s)
  {
    filename = s;
  }
  public int getParent()
  {
    return parent;
  }
  public void setParent(int i)
  {
    parent = i;
  }
  public int getOwnerid()
  {
    return ownerid;
  }
  public void setOwnerid(int i)
  {
    ownerid = i;
  }
  public long getSize()
  {
    return size;
  }
  public String getSizeString()
  {
    if (size < 1024)
      return size + " bytes";
    else
    {
      return (size/1024) + " KB";
    }
  }
  public void setSize(long i)
  {
    size = i;
  }
  public boolean getIsfolder()
  {
    return isfolder;
  }
  public void setIsfolder(boolean i)
  {
    isfolder = i;
  }
  public short getVersion()
  {
    return version;
  }
  public void setVersion(short i)
  {
    version = i;
  }
  public long getAttributes()
  {
    return attributes;
  }
  public void setAttributes(long i)
  {
    attributes = i;
  }
  public String getDescription()
  {
    return description;
  }
  public void setDescription(String s)
  {
    description = s;
  }
  public String getType()
  {
    return type;
  }
  public void setType(String s)
  {
    type = s;
  }
  public Timestamp getCreatetime()
  {
    return createtime;
  }
  public String getCreatetimeString()
  {
    if ( createtime == null )
      return "";
    else
    {
      BoxStatic.dateTimeFormatter.applyPattern(BoxStatic.SHORT_DATETIME_FORMAT);
      return BoxStatic.dateTimeFormatter.format(createtime);
    }
  }
  public void setCreatetime(Timestamp i)
  {
    createtime = i;
  }
  public Timestamp getLastmodifiedtime()
  {
    return lastmodifiedtime;
  }
  public String getLastmodifiedtimeString()
  {
    if ( lastmodifiedtime == null )
      return "";
    else
    {
      BoxStatic.dateTimeFormatter.applyPattern(BoxStatic.SHORT_DATETIME_FORMAT);
      return BoxStatic.dateTimeFormatter.format(lastmodifiedtime);
    }
  }
  public void setLastmodifiedtime(Timestamp i)
  {
    lastmodifiedtime = i;
  }

  public String toString()
  {
    StringBuffer str = new StringBuffer();
    str.append("id=");
    str.append(id);
    str.append(", ");
    str.append("name=");
    str.append(name);
    str.append(", ");
    str.append("filename=");
    str.append(filename);
    str.append(", ");
    str.append("ownerid=");
    str.append(ownerid);
    str.append(", ");
    str.append("parent=");
    str.append(parent);
    str.append(", ");
    str.append("size=");
    str.append(size);
    str.append(", ");
    str.append("isfolder=");
    str.append(isfolder);
    str.append(", ");
    str.append("version=");
    str.append(version);
    str.append(", ");
    str.append("attributes=");
    str.append(attributes);
    str.append(", ");
    str.append("description=");
    str.append(description);
    str.append(", ");
    str.append("createtime=");
    str.append(createtime);
    str.append(", ");
    str.append("lastmodifiedtime=");
    str.append(lastmodifiedtime);
    return str.toString();
  }
}
